alter PROCEDURE getDataChange @BatchNumber varchar(200),
                               @change_type VARCHAR(200),
    --                               @begingmt_create DATETIME,
--                               @endgmt_create DATETIME,
                               @PageIndex INT,
                               @PageSize INT,
                               @TotalCount INT OUTPUT
AS
BEGIN
    SET NOCOUNT ON;

    -- 计算分页的起始位置
    DECLARE @Offset INT = (@PageIndex - 1) * @PageSize;
--------------------------------------------------------------------------------------------
    select a.batch_number       工单号,
           a.change_type        变更类型,
           a.before_change_info 变更前信息,
           a.after_change_info  变更后信息,
           a.changed_by         变更人,
           a.change_time        变更时间,
           b.gmt_create         mes创建时间

    from mes_bo_import_data_change_log a
             left join mes_batch_order b on b.id = a.bo_id

------------------------------------------------------------------------------------------------------


    WHERE (@BatchNumber IS NULL OR a.batch_number = @BatchNumber)
--       AND (@begingmt_create IS NULL OR a.gmt_create >= @begingmt_create)
--       AND (@endgmt_create IS NULL OR a.gmt_create <= @endgmt_create)
      AND (@change_type IS NULL OR a.change_type = @change_type)


    ORDER BY a.gmt_create -- 根据需要选择排序字段
    OFFSET @Offset ROWS FETCH NEXT @PageSize ROWS ONLY;

    SELECT @TotalCount = COUNT(1)

    ---------------------------------------------------------------------

    from mes_bo_import_data_change_log a
             left join mes_batch_order b on b.id = a.bo_id
    -------------------------------------------

    WHERE (@BatchNumber IS NULL OR a.batch_number = @BatchNumber)
--       AND (@begingmt_create IS NULL OR a.gmt_create >= @begingmt_create)
--       AND (@endgmt_create IS NULL OR a.gmt_create <= @endgmt_create)
      AND (@change_type IS NULL OR a.change_type = @change_type)

END